﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VideoClassLibrary;
using VideoClassLibrary.Model;
using VideoClassLibrary.BusinessLogicLayer;
public partial class AdminManagement_AdminList :AdminUserBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindPageData();
        }
    }
    public void bindPageData()
    {
        AdminModule am = new AdminModule();
        DataSet admin = new DataSet();
        if (this.SchoolID == 0)
        {
            admin = am.GetAllAdmin();
        }
        else
        {
            admin = am.GetAdmin(this.SchoolID);
        }
        rptCoursewareList.DataSource =getPage(admin);
        rptCoursewareList.DataBind();
    }
    public string GetSchNameByID(int schid)
    {
        TeacherModule ta = new TeacherModule();
        string name = ta.GetSchNameByID(schid);
        return name;
    }
    public string GetTypeByID(int typeid)
    {
        string rtn = string.Empty;
        switch (typeid)
        {
            case 0:
                rtn = "运营商管理员";
                break;
            case 1:
                rtn = "学校管理员";
                break;
            case 2:
                rtn = "课程内务";
                break;
            case 3:
                rtn = "招生负责人";
                break;
            case 4:
                rtn = "网站编辑";
                break;
        }
        return rtn;
    }
    protected void pager_PageChanged(object sender,EventArgs e)
    {
        bindPageData();
    }
    public PagedDataSource getPage(DataSet ds)
    {
        this.pager.RecordCount = ds.Tables[0].Rows.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
        pds.PageSize = pager.PageSize;

        return pds;
    }
    public void btnUpdate_Click(object sender, CommandEventArgs e)
    {
        Response.Redirect("UpdateAdmin.aspx?AdID=" + e.CommandArgument.ToString());
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("AddAdminUser.aspx");
    }
}
